/**
 * Covalent Server Header File
 * 
 * File:        thread_helper.h
 * Brief:       BRIEF
 * Author:      Chen Kangbing
 * Email:       ckblau@outlook.com
 * Modified:    2021/10/08 17:06:19
 *
 */


#ifndef THREAD_HELPER_H
#define THREAD_HELPER_H

#ifdef __cplusplus
extern "C" {
#endif 


#include <pthread.h>

#include "prototype.h"


typedef void *(THREAD_BODY)(void *thread_arg);
void *thread_worker(void *ctx);


int thread_start(pthread_t *thread_id, THREAD_BODY *thread_workbody, void *thread_arg);
int thread_init_pool(ServerTypeDef *psrv, THREAD_BODY *thread_workbody);
void task_add(ServerTypeDef *psrv, WorkerTaskTypeDef *ptask);
void task_get(WorkerThreadTypeDef *pworker);
void task_finish(WorkerThreadTypeDef *pworker);


#ifdef __cplusplus
}
#endif 

#endif
